<template>
	<view class="activate-spotGoods-wrap">
		<view class="topVue">
			<view class="status"></view>
			<view class="navVue">
				<image src="../../static/imgs/back.png" style="width: 36rpx; height: 36rpx;" @click="backFun"></image>
				<view class="nav-title">激活现货量化</view>
				<view style="width: 36rpx; height: 36rpx;"></view>
			</view>
		</view>

		<view class="place"></view>

		<view class="cost-wrap">
			<p class="label">{{ $t("费用") }}</p>
			<p class="value"><span>100</span> <span>USDT</span></p>
		</view>

		<view class="info-wrap">
			<view class="period-validity-wrap">
				<view class="title">{{ $t("有效期限") }}</view>
				<view class="time">{{ nowDate }} ～ {{ nextDate }}</view>
				<view class="info">
					{{ $t( "激活后，才可订阅现货专业版策略，使用时间365天，从激活 开始日期算")}}
				</view>
			</view>
			<view class="transaction-password-wrap">
				<view class="title">{{ $t("交易密码") }}</view>
				<u--input type="password" :placeholder="$t('请输入交易密码')" border="surround" v-model="pwd"></u--input>
				<view class="info">{{ $t("输入交易密码后，费用从服务费扣除") }}</view>
			</view>
			<u-button type="primary" :text="$t('确认')" class="confirm-btn" @click="submit"></u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pwd: "",
				nowDate: "",
				nextDate: "",
			};
		},
		methods: {
			backFun(){
				uni.navigateBack({
					delta: 1
				})
			},

			submit() {
				console.log(this.pwd, "pwd");
				if (!this.pwd) {
					uni.$u.toast(this.$t("请输入交易密码"));
					return;
				}
				this.$http
					.post(`/front/trade/activeTrade?tradePwd=${this.pwd}`)
					.then((res) => {
						console.log(res, 124);
						if (res.code === 0) {
							uni.$u.toast(this.$t("操作成功"));
							uni.setStorageSync("apiStatus", true);
							// 返回上一个页面
							uni.navigateBack({
								delta: 1,
							});
						}
					})
					.catch((err) => {
						console.error(err);
					});
			},
		},
		onLoad() {
			let now = new Date();
			// 获取年份
			let year = now.getFullYear();

			// 获取月份（注意要加1，因为从0开始算）
			let month = now.getMonth() + 1;
			// 获取日期
			let date = now.getDate();
			this.nowDate = year + "-" + month + "-" + date;

			let targetDate = new Date(now.setDate(now.getDate() + 365))
			let a = targetDate.getFullYear()
			let b = targetDate.getMonth() + 1;
			let c = targetDate.getDate();
			console.log(targetDate, "kkk", a, b, c)
			this.nextDate = a + "-" + b + "-" + c;

			// let noww = new Date();
			// let yearAfter = new Date();
			// yearAfter.setFullYear(noww.getFullYear() + 1);
			// // 获取年份、月份和日期
			// let afteryear = yearAfter.getFullYear();
			// let aftermonth = yearAfter.getMonth() + 1;
			// let afterate = yearAfter.getDate();
			// this.nextDate = afteryear + "-" + aftermonth + "-" + afterate;
		},
	};
</script>

<style lang="scss" scoped>
	.activate-spotGoods-wrap {
		width: 100%;
		height: 100%;
		background: url("../../static/imgs/bg.png") no-repeat;
		background-size: 100% 100%;
		box-sizing: border-box;
		position: fixed;

		.place {
			height: calc(var(--status-bar-height) + 92rpx);
		}

		.topVue {
			width: 100%;
			position: absolute;
			left: 0;
			top: 0;
			z-index: 99;

			.status {
				width: 100%;
				height: var(--status-bar-height);
			}

			.navVue {
				width: 100%;
				height: 92rpx;
				background: linear-gradient(to right, #FFFBFF, #FFE7F4);
				display: flex;
				justify-content: space-between;
				align-items: center;
				box-sizing: border-box;
				padding: 0 30rpx;

				.nav-title {
					width: 420rpx;
					height: 92rpx;
					font-size: 36rpx;
					color: #04094C;
					text-align: center;
					line-height: 92rpx;
				}
			}
		}

		.cost-wrap {
			width: 690rpx;
			height: 98rpx;
			background: #FFFFFF;
			box-shadow: 0px 4rpx 20rpx 0px rgba(0,0,0,0.05);
			border-radius: 20rpx;
			box-sizing: border-box;
			margin: 30rpx auto;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 20rpx;
			.label {
				font-size: #333;
			}

			.value {
				font-size: #333;
				font-weight: 600;
			}
		}

		.info-wrap {
			width: 690rpx;
			min-height: calc(100vh - 414rpx);
			background-color: #fff;
			box-sizing: border-box;
			padding: 50rpx 25rpx;
			margin: 30rpx auto;
			.title {
				font-size: $uni-font-size-36;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333;
				margin-bottom: 50rpx;
			}

			.time {
				font-size: $uni-font-size-28;
				font-family: PingFang SC;
				font-weight: 400;
				color: #333;
				padding-bottom: 30rpx;
				border-bottom: 2rpx solid $uni-border-bottom-color;
			}

			.info {
				font-size: $uni-font-size-26;
				font-family: PingFang SC;
				font-weight: 300;
				color: #333;
				margin-top: 43rpx;
				line-height: 48rpx;
			}

			.transaction-password-wrap {
				margin-top: 80rpx;
			}

			/deep/ .u-input {
				background-color: transparent;
				height: 101rpx;
				border: 1px solid $uni-border-bottom-color !important;
				border-radius: 20rpx;
			}
		}

		.confirm-btn {
			margin-top: 124rpx;
			width: 100%;
			height: 90rpx;
			background: #D55B94;
			border-color: $uni-theme-color;
			border-radius: 20rpx;
			font-size: $uni-font-size-30;
			font-family: PingFang SC;
			font-weight: 400;
		}
	}
</style>
